package org.ls.petclinic.web;

import cn.hutool.core.util.ObjectUtil;
import com.google.gson.Gson;
import org.ls.petclinic.dao.PetsDao;
import org.ls.petclinic.dao.SpecialtiesDao;
import org.ls.petclinic.dao.VetSpecialtiesDao;
import org.ls.petclinic.dao.impl.PetsDaoImpl;
import org.ls.petclinic.dao.impl.SpecialtiesDaoImpl;
import org.ls.petclinic.dao.impl.VetSpecialtiesDaoImpl;
import org.ls.petclinic.pojo.Pets;
import org.ls.petclinic.pojo.Specialties;
import org.ls.petclinic.untils.JdbcUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @author 浪矢先生
 * @description
 * @create 2022-12-05 23:22
 */
@WebServlet(urlPatterns = "/getSpecialty")
public class GetSpecialtyInfo extends BaseServlet {
    private SpecialtiesDao specialtiesDao=new SpecialtiesDaoImpl();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        Gson gson = new Gson();
        resp.setCharacterEncoding("utf-8");
        resp.setContentType("application/json");
        List<Specialties> all = specialtiesDao.getAll();
        JdbcUtils.commitAndClose();
        resp.getWriter().write(String.valueOf(gson.toJson(all)));
    }
}
